<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
    <div region="center" style="padding:1px;">
        <t:datagrid name="zyEquipmentTypeList" checkbox="false" fitColumns="false" title="设备机型" treegrid="true" pagination="false" onDblClick="dbClick"
                    actionUrl="cbsEquipmentApplyController.do?dataGridOfChooseEquipmentType" idField="id" fit="true" queryMode="group">
            <t:dgCol title="主键"  field="id"  hidden="true" treefield="id"	 width="120"></t:dgCol>
            <t:dgCol title="机型名"  field="typeDesc" 		treefield="text"	width="250"></t:dgCol>
        </t:datagrid>
    </div>
</div>
<script src = "webpage/com/zybk/zy_em_valida_rule/zyEmValidaRuleList.js"></script>
<script type="text/javascript">
    function dbClick(node){
        <%
              String uuid = request.getParameter("uuid");
              String id = request.getParameter("id");
              String aId = request.getParameter("aId");
        %>
        var uuid = '<%=uuid%>';//输出s2给js变量s
        var applyId = '<%=id%>';
        var aId = '<%=aId%>';
        /*aid = decodeURI(aid)*/
        if(!node.hasLeaf){
            if(applyId!="null"){
                var id=node.id;
                $("#"+applyId,top.myWindow.document).val(node.id);
                $("#"+applyId+"0",top.myWindow.document).val(node.text);
                $.ajax({
                    url: "cbsEquipmentApplyController.do?getItem",
                    data: {
                        "id":id,
                        "applyId":applyId,
                        "aId":aId
                    },
                    cache: false,
                    dataType: 'json',
                    type: 'POST',
                    error : function() {// 请求失败处理函数
                    },
                    success : function(data) {
                        if(data==null){
                            $("#"+applyId+"item",top.myWindow.document).hide();
                            $("#"+applyId+"in",top.myWindow.document).show();
                            $("#"+applyId+"itemDesc",top.myWindow.document).show();
                            $("#"+applyId+"span",top.myWindow.document).hide();
                        }else{
                            $("#"+applyId+"item",top.myWindow.document).html("");
                            $("#"+applyId+"item",top.myWindow.document).show();
                            $("#"+applyId+"in",top.myWindow.document).hide();
                            var html="";
                            html+="<option value=''>请选择</option>";
                            for(a in data){
                                html+="<option value='"+data[a].id+"'>"+data[a].item+"</option>"
                            }
                            $("#"+applyId+"item",top.myWindow.document).append(html);
                        }
                        frameElement.api.close();
                    }
                });
            }else{
                var id=node.id;
                $("#"+uuid,top.myWindow.document).val(node.id);
                $("#"+uuid+"0",top.myWindow.document).val(node.text);
                $.ajax({
                    url: "cbsEquipmentApplyController.do?getItem",
                    data: {
                        "id":id,
                        "applyId":applyId,
                        "aId":aId
                    },
                    cache: false,
                    dataType: 'json',
                    type: 'POST',
                    error : function() {// 请求失败处理函数
                    },
                    success : function(data) {
                        if(data==null){
                            $("#"+uuid+"item",top.myWindow.document).hide();
                            $("#"+uuid+"in",top.myWindow.document).show();
                            $("#"+uuid+"itemDesc",top.myWindow.document).show();
                            $("#"+uuid+"span",top.myWindow.document).hide();
                        }else{
                            $("#"+uuid+"item",top.myWindow.document).html("");
                            $("#"+uuid+"item",top.myWindow.document).show();
                            $("#"+uuid+"in",top.myWindow.document).hide();
                            var html="";
                            html+="<option value=''>请选择</option>";
                            for(a in data){
                                html+="<option value='"+data[a].id+"'>"+data[a].item+"</option>"
                            }
                            $("#"+uuid+"item",top.myWindow.document).append(html);
                        }
                        frameElement.api.close();
                    }
                });
            }
        }else{
            tip("请选择正确的机型");
        }
    }
</script>